#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i) 
#define mkp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

const int N = 1e6+9;
const int inf = 1e9+9;
const double eps = 1e-7;
int _,n,m,a[2*N],cnt,cntt,dp[2*N],ans,tmp,lim;

struct node{
    int x,y;
}rob[2*N],lig[2*N],q[2*N],safe[2*N];
inline bool cmp(node x,node y){return x.x < y.x;}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef LOCAL //use "g++ xxx.cpp -DLOCAL"
        freopen("in.in", "r", stdin);
    #endif
    cin >> n >> m;
    rep(i,1,n) cin >> rob[i].x >> rob[i].y;
    rep(i,1,m) cin >> lig[i].x >> lig[i].y;
    rep(i,1,std::max(n,m)) lim = std::max({lim,rob[i].x,rob[i].y,lig[i].x,lig[i].y});
    rep(i,1,m){
        node no = lig[i];
        rep(j,1,n){
            node now = rob[j];
            if(no.x >= now.x && no.y >= now.y)
            dp[ no.x-now.x ] = std::max(dp[ no.x-now.x ] , no.y - now.y + 1);
        }
    }
    ans = inf , tmp = 0;
    per(i,lim,0){
        tmp = std::max(tmp,dp[i]);
        ans = std::min(tmp+i,ans);
        // cout << tmp << " " << i << "\n";
    }
    cout << ans << "\n";
    return 0;
}